<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>世界战争模拟器 - 主菜单</title>
    <script src="settings.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background-color: #2c3e50;
            color: #ecf0f1;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-image: url('https://images.unsplash.com/photo-1534330207526-8e81f10ec6fc?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
            background-size: cover;
            background-position: center;
            position: relative;
        }

        body::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 1;
        }

        .menu-container {
            background-color: rgba(44, 62, 80, 0.9);
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
            padding: 40px;
            text-align: center;
            max-width: 500px;
            width: 90%;
            position: relative;
            z-index: 2;
        }

        .game-title {
            font-size: 2.5rem;
            margin-bottom: 10px;
            color: #e74c3c;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
        }

        .game-subtitle {
            font-size: 1.2rem;
            margin-bottom: 40px;
            color: #bdc3c7;
        }

        .menu-buttons {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .menu-button {
            padding: 15px 20px;
            font-size: 1.2rem;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .menu-button::after {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: 0.5s;
        }

        .menu-button:hover {
            background-color: #2980b9;
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
        }

        .menu-button:hover::after {
            left: 100%;
        }

        .menu-button:active {
            transform: translateY(0);
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
        }

        .start-game {
            background-color: #2ecc71;
        }

        .start-game:hover {
            background-color: #27ae60;
        }

        .continue-game {
            background-color: #e67e22;
        }

        .continue-game:hover {
            background-color: #d35400;
        }

        .game-settings {
            background-color: #9b59b6;
        }

        .game-settings:hover {
            background-color: #8e44ad;
        }

        .version {
            position: absolute;
            bottom: 10px;
            right: 10px;
            font-size: 0.8rem;
            color: #7f8c8d;
        }
        
        /* 设置面板样式 */
        .settings-panel {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10;
        }
        
        .settings-content {
            background-color: rgba(44, 62, 80, 0.95);
            border-radius: 10px;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
            padding: 30px;
            width: 80%;
            max-width: 600px;
            max-height: 90vh;
            overflow-y: auto;
        }
        
        .settings-content h2 {
            color: #e74c3c;
            text-align: center;
            margin-bottom: 20px;
            font-size: 1.8rem;
            border-bottom: 1px solid #3498db;
            padding-bottom: 10px;
        }
        
        .settings-section {
            margin-bottom: 25px;
        }
        
        .settings-section h3 {
            color: #3498db;
            margin-bottom: 10px;
            font-size: 1.3rem;
        }
        
        .setting-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
            padding: 8px;
            background-color: rgba(52, 73, 94, 0.5);
            border-radius: 5px;
        }
        
        .setting-item label {
            flex: 1;
        }
        
        .setting-item input[type="number"],
        .setting-item input[type="range"],
        .setting-item select {
            width: 120px;
            padding: 5px;
            border-radius: 4px;
            border: 1px solid #3498db;
            background-color: #2c3e50;
            color: white;
        }
        
        .setting-item input[type="checkbox"] {
            width: 20px;
            height: 20px;
            accent-color: #3498db;
        }
        
        .settings-buttons {
            display: flex;
            justify-content: space-between;
            margin-top: 20px;
        }
        
        .settings-button {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s;
        }
        
        #save-settings {
            background-color: #2ecc71;
            color: white;
        }
        
        #save-settings:hover {
            background-color: #27ae60;
        }
        
        #reset-settings {
            background-color: #e74c3c;
            color: white;
        }
        
        #reset-settings:hover {
            background-color: #c0392b;
        }
        
        #close-settings {
            background-color: #7f8c8d;
            color: white;
        }
        
        #close-settings:hover {
            background-color: #95a5a6;
        }
    </style>
</head>
<body>
    <div class="menu-container">
        <h1 class="game-title">世界战争模拟器</h1>
        <p class="game-subtitle">体验史诗级战略战棋游戏</p>
        
        <div class="menu-buttons">
            <button class="menu-button start-game" onclick="startNewGame()">开始游戏</button>
            <button class="menu-button continue-game" onclick="continueGame()">继续游戏</button>
            <button class="menu-button game-settings" onclick="openSettings()">游戏设置</button>
        </div>
        
        <div class="version">v1.0.0</div>
    </div>

    <!-- 设置面板 -->
    <div id="settings-panel" class="settings-panel" style="display: none;">
        <div class="settings-content">
            <h2>游戏设置</h2>
            
            <div class="settings-section">
                <h3>游戏难度</h3>
                <div class="setting-item">
                    <label>难度级别:</label>
                    <select id="difficulty-select">
                        <option value="easy">简单</option>
                        <option value="normal">普通</option>
                        <option value="hard">困难</option>
                    </select>
                </div>
            </div>
            
            <div class="settings-section">
                <h3>游戏规则</h3>
                <div class="setting-item">
                    <label>初始资源:</label>
                    <input type="number" id="initial-resources" min="50" max="500" step="10">
                </div>
                <div class="setting-item">
                    <label>每回合资源:</label>
                    <input type="number" id="resources-per-turn" min="5" max="100" step="5">
                </div>
            </div>
            
            <div class="settings-section">
                <h3>界面设置</h3>
                <div class="setting-item">
                    <label>显示网格线:</label>
                    <input type="checkbox" id="show-grid-lines">
                </div>
                <div class="setting-item">
                    <label>显示单位生命值:</label>
                    <input type="checkbox" id="show-unit-health">
                </div>
                <div class="setting-item">
                    <label>主题:</label>
                    <select id="theme-select">
                        <option value="default">默认</option>
                        <option value="dark">暗黑</option>
                        <option value="light">明亮</option>
                    </select>
                </div>
            </div>
            
            <div class="settings-section">
                <h3>音效设置</h3>
                <div class="setting-item">
                    <label>背景音乐:</label>
                    <input type="checkbox" id="music-enabled">
                </div>
                <div class="setting-item">
                    <label>音效:</label>
                    <input type="checkbox" id="sound-effects-enabled">
                </div>
                <div class="setting-item">
                    <label>音量:</label>
                    <input type="range" id="volume-slider" min="0" max="1" step="0.1">
                </div>
            </div>
            
            <div class="settings-buttons">
                <button id="save-settings" class="settings-button">保存设置</button>
                <button id="reset-settings" class="settings-button">重置默认</button>
                <button id="close-settings" class="settings-button">关闭</button>
            </div>
        </div>
    </div>

    <script>
        // 当页面加载完成时初始化设置面板
        document.addEventListener('DOMContentLoaded', function() {
            // 填充设置面板的值
            document.getElementById('difficulty-select').value = gameSettings.difficulty;
            document.getElementById('initial-resources').value = gameSettings.initialResources;
            document.getElementById('resources-per-turn').value = gameSettings.resourcesPerTurn;
            document.getElementById('show-grid-lines').checked = gameSettings.ui.showGridLines;
            document.getElementById('show-unit-health').checked = gameSettings.ui.showUnitHealth;
            document.getElementById('theme-select').value = gameSettings.ui.theme;
            document.getElementById('music-enabled').checked = gameSettings.audio.musicEnabled;
            document.getElementById('sound-effects-enabled').checked = gameSettings.audio.soundEffectsEnabled;
            document.getElementById('volume-slider').value = gameSettings.audio.volume;
            
            // 设置版本号
            document.querySelector('.version').textContent = 'v' + gameSettings.version;
        });
        
        function startNewGame() {
            // 重置游戏状态
            localStorage.removeItem('wws_gameState');
            // 跳转到游戏页面
            window.location.href = 'index.html';
        }
        
        function continueGame() {
            // 检查是否有保存的游戏
            const savedGame = localStorage.getItem('wws_gameState');
            if (savedGame) {
                window.location.href = 'index.html?continue=true';
            } else {
                alert('没有找到已保存的游戏！');
            }
        }
        
        function openSettings() {
            // 显示设置面板
            document.getElementById('settings-panel').style.display = 'flex';
        }
        
        // 保存设置按钮
        document.getElementById('save-settings').addEventListener('click', function() {
            // 获取设置值
            gameSettings.difficulty = document.getElementById('difficulty-select').value;
            gameSettings.initialResources = parseInt(document.getElementById('initial-resources').value);
            gameSettings.resourcesPerTurn = parseInt(document.getElementById('resources-per-turn').value);
            gameSettings.ui.showGridLines = document.getElementById('show-grid-lines').checked;
            gameSettings.ui.showUnitHealth = document.getElementById('show-unit-health').checked;
            gameSettings.ui.theme = document.getElementById('theme-select').value;
            gameSettings.audio.musicEnabled = document.getElementById('music-enabled').checked;
            gameSettings.audio.soundEffectsEnabled = document.getElementById('sound-effects-enabled').checked;
            gameSettings.audio.volume = parseFloat(document.getElementById('volume-slider').value);
            
            // 保存设置
            saveSettings();
            
            // 关闭设置面板
            document.getElementById('settings-panel').style.display = 'none';
            
            alert('设置已保存！');
        });
        
        // 重置设置按钮
        document.getElementById('reset-settings').addEventListener('click', function() {
            if (confirm('确定要重置所有设置为默认值吗？')) {
                resetSettings();
            }
        });
        
        // 关闭设置按钮
        document.getElementById('close-settings').addEventListener('click', function() {
            document.getElementById('settings-panel').style.display = 'none';
        });
    </script>
</body>
</html>